package by.kniazhych.core.frames {
	import by.kniazhych.core.constants.UserColor;
	import by.kniazhych.core.controllers.GameController;
	import by.kniazhych.core.controllers.BaseFrameController;
	import by.kniazhych.core.server.local.LocalServerProxy;
	import by.kniazhych.core.view.frames.AuthorsFrame;
	import by.kniazhych.core.view.frames.GameFrameView;
	import by.kniazhych.core.view.frames.MenuFrame;
	import by.kniazhych.core.view.frames.RulesFrame;
	import by.vaukalak.core.controllers.BaseController;
	import design.board.BackGround;
	import design.frames.Authors;
	import design.menu.Menu;
	
	/**
	 * ...
	 * @author Boutylin Mikhail
	 */
	
	
	
	public class FrameBuilder{
		private var _target:BaseController;
		
		public function FrameBuilder(target:BaseController) {
			_target = target;
		}
		
		public function buildFrame(frameName:String):BaseFrameController {
			var frame:BaseFrameController;
			switch(frameName) {
				case ApplicationFrame.MENU:
					frame = new BaseFrameController(_target);
					frame.constuctFrame(new MenuFrame());
				break;
				case ApplicationFrame.AUTHORS:
					frame = new BaseFrameController(_target);
					frame.constuctFrame(new AuthorsFrame());
				break;
				case ApplicationFrame.MULTYPLAYER:
					frame = new GameController(_target, UserColor.WHITE, new LocalServerProxy());//TODO: add multiplayer frame
					frame.constuctFrame(new GameFrameView());
				break;
				case ApplicationFrame.RULES:
					frame = new BaseFrameController(_target);
					frame.constuctFrame(new RulesFrame());
				break;
				case ApplicationFrame.SINGLE_GAME_WHITE:
					frame = new GameController(_target, UserColor.WHITE, new LocalServerProxy());
					frame.constuctFrame(new GameFrameView());
				break;
				case ApplicationFrame.SINGLE_GAME_BLACK:
					frame = new GameController(_target, UserColor.BLACK, new LocalServerProxy());
					frame.constuctFrame(new GameFrameView());
				break;
				default: throw new ArgumentError("unknown frame");
			}
			return frame;
		}
		
	}

}